package com.system.service.imp;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.common.util.CopyUtil;
import com.core.system.domain.Apicode;
import com.core.system.mapper.ApicodeMapper;
import com.system.Excel.ApicodeExcel;
import com.system.mapper.ApicodeExMapper;
import com.system.service.ApicodeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;


@Service
@Primary
public class ApicodeExServiceImp extends com.core.service.imp.ApicodeServiceImp implements ApicodeService {
    @Autowired
    private ApicodeMapper apicodeMapper;
    @Autowired
    private ApicodeExMapper apicodeExMapper;





    @Override
    @Transactional(propagation = Propagation.NEVER, isolation = Isolation.READ_COMMITTED)
    public boolean inertList(List<Apicode> apicodeList, String module) {
        apicodeMapper.delete(new LambdaQueryWrapper<Apicode>().eq(module!=null,Apicode::getModule, module));
        return apicodeExMapper.insertApicodeList(apicodeList) > 0;

    }


    @Override
    public List<ApicodeExcel> ExportList() {
        List<Apicode> apicodeList = apicodeMapper.selectList(new LambdaQueryWrapper<Apicode>().orderBy(true, false, Apicode::getCreateTime));
        return CopyUtil.copyList(apicodeList, ApicodeExcel.class);
    }

}
